package Week6.J0524;

import java.util.Scanner;

public class 奇数位丢弃 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int ret = 1;
            while (ret - 1 <= n) ret *= 2;
            System.out.println(ret / 2 - 1);
        }
    }
}
